home *** CD-ROM | disk | FTP | other *** search
/ Aminet 37 / Aminet 37 (2000)(Schatztruhe)[!][Jun 2000].iso / Aminet / dev / basic / PureBasic.lha / PureBasic_Demo / PureBasic / Examples / FullVersion_Sources / WildManager.pb < prev   
Encoding:
Text File  |  2000-03-19  |  12.9 KB  |  635 lines

  1. ;
  2. ;
  3. ; ---------->        <------
  4. ; Wild Manager      V1.01
  5. ; ------------>    <--------
  6. ;
  7. ; © 1999 - Fantaisie Software - Coded by AlphaSND
  8. ;       
  9. ;
  10. ; Description: Preference front-end for the WILD 3D package from 'Pyper'
  11. ;     
  12. ;
  13. ; NOTE:
  14. ; -----
  15. ;
  16. ; A String in a linked list must not be to NULL for the listview, else
  17. ; we got an enforcer hit (AmigaOS 'bug') !
  18. ;
  19. ;
  20.  
  21. WBStartup()
  22.  
  23. InitScreen(0)
  24. InitWindow(0)
  25. InitGadget(0)
  26. InitFile  (0)
  27.  
  28. If InitRequester() = 0
  29.   End
  30. EndIf
  31.  
  32. *TagList = InitTagList(10)  ; Note you can use TagListID() but using a variable is smaller/faster
  33.  
  34. Mode.s
  35.  
  36. Structure PBScreenInfo
  37.   DisplayID.l     ; Display mode ID
  38.   Width.l         ; Width of display in pixels
  39.   Height.l        ; Height of display in pixels
  40.   Depth.w         ; Number of bit-planes of display
  41.   OverscanType.w  ; Type of overscan of display
  42.   AutoScroll.b
  43. EndStructure
  44.  
  45.  
  46. Structure NLVList
  47.   Pad.w
  48.   Item.s
  49.   Command.s
  50.   Processors.b
  51.   Rendering.b
  52.   Warp3D.b
  53.   Width.w
  54.   Height.w
  55.   ScreenID.l
  56.   Changed.b
  57.   AGA.b
  58. EndStructure
  59.  
  60. NewList PL.NLVList()
  61.  
  62. ;
  63. ; Read pref file..
  64. ;
  65. ;LoadPref
  66.  
  67. If ReadFile(0, "PROGDIR:WildManager.pref")
  68.  
  69.   a$ = ReadString()
  70.   If a$ = "WildManagerPref1"
  71.     NbProg = ReadWord()
  72.  
  73.     For k=0 To NbProg-1
  74.       If AddElement(PL())
  75.         PL()\Item       = ReadString()
  76.         PL()\Command    = ReadString()
  77.         PL()\Processors = ReadByte()
  78.         PL()\Rendering  = ReadByte()
  79.         PL()\Warp3D     = ReadByte()
  80.         PL()\Width      = ReadWord()
  81.         PL()\Height     = ReadWord()
  82.         PL()\ScreenID   = ReadLong()
  83.         PL()\AGA        = ReadByte()
  84.       EndIf
  85.  
  86.       a$ = ReadString() ; "WAM_End_WAM"
  87.     Next
  88.  
  89.   EndIf
  90.  
  91.   CloseFile(0)
  92. Else
  93.   NoPref = 1
  94. EndIf
  95.  
  96. If NbProg<1 OR NoPref
  97.   AddElement(PL())
  98.   PL()\Item = "Program 1"
  99.   NbProg = 1
  100. EndIf
  101.  
  102. FirstElement(PL())
  103.  
  104. Dim Language.s(8)
  105.  
  106. *MyScreen = FindScreen(0,"Workbench")
  107.  
  108. ;
  109. ; Now, create all the windows gadgets
  110. ;
  111.  
  112. If CreateGadgetList(0, ScreenID())
  113.  
  114.   HG     = 20
  115.   HFont  = ScreenFontHeight()
  116.   HFont3 = HFont+3
  117.   HFont6 = HFont+6
  118.  
  119.   Top = HG
  120.  
  121.   ResetTagList(#GTST_MaxChars,100)
  122.         AddTag(#GA_Immediate, 1)
  123.         AddTag(#GTST_String, PL()\Item)
  124.   StringGadget(1, 210, HG, 200, HFont6, "Name:", *TagList) : HG=HG+HFont6+2
  125.  
  126.  
  127.   a$ = "Fountain.exe"
  128.   ResetTagList(#GTST_MaxChars,1000)
  129.         AddTag(#GTST_String, PL()\Command)
  130.         AddTag(#GA_Immediate, 1)
  131.   StringGadget(2, 210, HG, 180, HFont6, "Program:", *TagList)
  132.  
  133.   ButtonGadget(16,  390, HG, 20, HFont6, "?"   , 0) : HG=HG+HFont6+10
  134.                                                                                                                               
  135.   Dim WildProcessor.s(2)
  136.   WildProcessor(0) = "680x0"
  137.   WildProcessor(1) = "PowerPC"
  138.  
  139.   ResetTagList(#GTCY_Labels, WildProcessor())
  140.         AddTag(#GTCY_Active, PL()\Processors)
  141.   SetGadgetFlags(#PLACETEXT_LEFT)
  142.   CycleGadget (7, 210, HG, 100, HFont6, "Amiga:", *TagList) : HG=HG+HFont6+2
  143.  
  144.   Dim WildRender.s(4)
  145.   WildRender(0) = "WireFrame"
  146.   WildRender(1) = "Flat"
  147.   WildRender(2) = "Gouraud"
  148.   WildRender(3) = "Textured"
  149.  
  150.   ResetTagList(#GTCY_Labels, WildRender())
  151.         AddTag(#GTCY_Active, PL()\Rendering)
  152.   SetGadgetFlags(#PLACETEXT_LEFT)
  153.   CycleGadget(8, 210, HG, 100, HFont6, "Rendering:", *TagList) : HG=HG+HFont6+2
  154.                                                                                                                               
  155.   ResetTagList(#GTCB_Scaled, 1)
  156.         AddTag(#GTCB_Checked, PL()\Warp3D)
  157.   SetGadgetFlags(#PLACETEXT_LEFT)
  158.   CheckBoxGadget(13, 210, HG, HFont6, HFont6, "Warp3D:", *TagList) : HG=HG+HFont6+2
  159.  
  160.   TextGadget(11,  210, HG,  0, HFont6, "Screen:" , 0)
  161.   SetGadgetFlags(#PLACETEXT_IN)
  162.  
  163.   TextGadget(20,  330, HG,  80, HFont6, "" , 0)
  164.  
  165.   Dim WildScreen.s(2)
  166.   WildScreen(0) = "CGFX"
  167.   WildScreen(1) = "AGA"
  168.  
  169.   ResetTagList (#GTCY_Labels, WildScreen())
  170.         AddTag (#GTCY_Active, PL()\AGA)
  171.   CycleGadget  (21,  210, HG, 60, HFont6, "", *TagList)
  172.   ButtonGadget (10,  272, HG, 50, HFont6, "Set", 0) : HG=HG+HFont6+HFont
  173.  
  174.   If PL()\Command = ""
  175.     a=1
  176.   Else
  177.     a=0
  178.   Endif
  179.  
  180.   ResetTagList (#GA_Disabled, a)
  181.   ButtonGadget (17,  210, HG, 200, HFont6, "-> Launch IT ! <-"   , *TagList)
  182.  
  183.   *RealList = ListBase(PL())
  184.  
  185.   ResetTagList (#GTLV_Labels, *RealList)
  186.         AddTag (#GTLV_ShowSelected, 0)
  187.         AddTag (#GTLV_Selected, 0)
  188.   SetGadgetFlags (#PLACETEXT_ABOVE)
  189.   *a.Gadget = ListViewGadget(9, 12, Top+HFont+7, 100, HG-Top-(HFont+7), "Programs:", *TagList)
  190.   ListViewGadget(9, 12, Top+HFont+7, 100, HG-Top-(HFont+7), "Programs:", *TagList)
  191.  
  192.   real = Top+HFont+9+*a\Height
  193.  
  194.   SetGadgetFlags (#PLACETEXT_IN)
  195.   ButtonGadget   (14,  12, real, 49, HFont6, "Add", 0)
  196.   ButtonGadget   (15,  63, real, 49, HFont6, "Del", 0) : HG=HG+HFont6+16
  197.  
  198.   SetGadgetFlags (#PLACETEXT_IN)
  199.   ButtonGadget   (4,  12, HG, 125, HFont6+2, "Save"   , 0)
  200.   ButtonGadget   (5, 148, HG, 125, HFont6+2, "Use"    , 0)
  201.   ButtonGadget   (6, 285, HG, 125, HFont6+2, "Cancel" , 0)
  202.  
  203. EndIf
  204.  
  205. ;
  206. ; Open our window and attach gadgets & menus..
  207. ;
  208.  
  209. WinTitle$    = "Wild Manager V1.00"
  210. ScreenTitle$ = "Wild Manager - © 1999 Fantaisie Software"
  211.  
  212. ResetTagList (#WA_Title, @WinTitle$)
  213.       AddTag (#WA_CustomScreen, ScreenID())
  214.       AddTag (#WA_ScreenTitle, @ScreenTitle$)
  215.  
  216. ChangeIDCMP(#IDCMP_MOUSEMOVE | #LISTVIEWIDCMP | #IDCMP_CLOSEWINDOW | #IDCMP_GADGETUP | #IDCMP_GADGETDOWN | #IDCMP_MOUSEBUTTONS |#IDCMP_VANILLAKEY|#IDCMP_MENUPICK)
  217.  
  218. WHeight = HG+HFont+2
  219. If OpenWindow(0, ScreenWidth()/2-210, HFont+20, 416, WHeight, #WFLG_CLOSEGADGET | #WFLG_DRAGBAR | #WFLG_DEPTHGADGET | #WFLG_ACTIVATE | #WFLG_RMBTRAP, *TagList)
  220.  
  221.   BevelBox(WindowBorderLeft(),WindowBorderTop(),WindowInnerWidth(),WindowInnerHeight(),0)
  222.  
  223.   BevelBox(WindowBorderLeft()-1,HG-7,WindowInnerWidth()+2,2,1)
  224.  
  225.   AttachGadgetList(0, WindowID())
  226.  
  227.   Gosub DisableWarp3D
  228.   Gosub DisableDel
  229.  
  230.   Gosub RefreshScreenMode
  231.  
  232. MainLoop:
  233.   Repeat
  234.  
  235.     Repeat
  236.       VWait()
  237.       IDCMP.l = WindowEvent()
  238.     Until IDCMP
  239.  
  240.     ; Special for mouseclick when editing a String !
  241.     ;
  242.     ;
  243.     If MustBeRefreshed
  244.       If MustBeRefreshed = 1
  245.         Gosub String1
  246.       Else
  247.         Gosub String2
  248.       EndIf
  249.  
  250.       MustBeRefreshed = 0
  251.     EndIf
  252.  
  253.  
  254.     Gadget = EventGadget()
  255.     Code   = EventCode()
  256.  
  257.     If IDCMP = #IDCMP_GADGETUP OR IDCMP = #IDCMP_GADGETDOWN ; A gadget has been pushed
  258.  
  259.       Select Gadget
  260.         Case 1
  261.           Gosub String1
  262.           MustBeRefreshed = 1
  263.  
  264.  
  265.         Case 2
  266.           Gosub String2
  267.           MustBeRefreshed = 2
  268.  
  269.  
  270.         Case 4 ; 'Save'
  271.           Gosub SavePrefs
  272.           IDCMP = #IDCMP_CLOSEWINDOW
  273.  
  274.  
  275.         Case 5 ; 'Use'
  276.           IDCMP = #IDCMP_CLOSEWINDOW
  277.  
  278.  
  279.         Case 6 ; 'Cancel'
  280.           IDCMP = #IDCMP_CLOSEWINDOW
  281.  
  282.  
  283.         Case 7
  284.           PL()\Processors = Code
  285.           PL()\Changed = 1
  286.  
  287.  
  288.         Case 8
  289.           PL()\Rendering = Code
  290.           PL()\Changed = 1
  291.  
  292.           Gosub DisableWarp3D
  293.  
  294.  
  295.         Case 9
  296.           ResetList(PL())
  297.  
  298.           For k=0 To Code
  299.             NextElement(PL())
  300.           Next
  301.  
  302.           Gosub RefreshWindow
  303.  
  304.  
  305.         Case 10
  306.  
  307.           ResetTagList (#ASLSM_DoWidth          , 1)
  308.                 AddTag (#ASLSM_DoHeight         , 1)
  309.                 AddTag (#ASLSM_DoOverscanType   , 1)
  310.                 AddTag (#ASLSM_InitialDisplayID , PL()\ScreenID)
  311.                 If PL()\Width
  312.                   AddTag (#ASLSM_InitialDisplayWidth  , PL()\Width)
  313.                   AddTag (#ASLSM_InitialDisplayHeight , PL()\Height)
  314.                 EndIf
  315.  
  316.           *sm.PBScreenInfo = ScreenRequester(*TagList)
  317.           If *sm
  318.             PL()\Width    = *sm\Width
  319.             PL()\Height   = *sm\Height
  320.             PL()\ScreenID = *sm\DisplayID
  321.           EndIf
  322.  
  323.           Gosub RefreshScreenMode
  324.  
  325.           PL()\Changed = 1
  326.  
  327.  
  328.         Case 13 ; 'Warp3D - On/Off'
  329.           PL()\Warp3D = Code
  330.           PL()\Changed = 1
  331.  
  332.  
  333.         Case 14 ; 'Add'
  334.  
  335.           NbProg = NbProg+1
  336.           AddElement(PL())
  337.           PL()\Item = ""
  338.  
  339.           GadgetAttrs(9, #GTLV_Labels, *RealList)
  340.           GadgetAttrs(9, #GTLV_Selected, ListIndex(PL()))
  341.  
  342.           RefreshGadget(9)
  343.           Gosub RefreshWindow
  344.  
  345.           ActivateGadget(1)
  346.  
  347.  
  348.         Case 15 ; 'Del'
  349.           KillElement(PL())
  350.  
  351.           NbProg = NbProg-1
  352.  
  353.           GadgetAttrs(9, #GTLV_Labels, *RealList)
  354.           RefreshGadget(9)
  355.           NextElement(PL())
  356.           Gosub RefreshWindow
  357.  
  358.  
  359.         Case 16
  360.  
  361.           b$ = PL()\Command
  362.  
  363.           file$ = GetFilePart(b$)
  364.           path$ = GetPathPart(b$)
  365.  
  366.           ResetTagList (#ASLFR_InitialTopEdge , WindowY()+WindowBorderTop())
  367.                 AddTag (#ASLFR_InitialLeftEdge, WindowX())
  368.                 AddTag (#ASLFR_InitialHeight  , ScreenHeight()/2)
  369.                 AddTag (#ASLFR_InitialWidth   , 200)
  370.                 AddTag (#ASLFR_InitialFile    , file$)
  371.                 AddTag (#ASLFR_InitialDrawer  , path$)
  372.  
  373.           ; STOP
  374.  
  375.           a$ = FileRequester(*TagList)
  376.  
  377.           If a$ <> ""
  378.             SetStringText(2, a$)
  379.             RefreshGadget(2)
  380.             Gosub String2
  381.           EndIf
  382.  
  383.  
  384.         Case 17 ; 'Launch IT !'
  385.           Gosub SetPref
  386.           PL()\Changed = 0
  387.  
  388.           b$ = GetPathPart(PL()\Command)
  389.  
  390.           RunProgram(b$, Chr(34)+PL()\Command+Chr(34), 1, 8192)
  391.  
  392.         Case 21 ; 'AGA - CGFX'
  393.           PL()\AGA = Code
  394.           PL()\Changed = 1
  395.  
  396.  
  397.       EndSelect
  398.     EndIf
  399.  
  400.   Until IDCMP = #IDCMP_CLOSEWINDOW
  401.  
  402. EndIf
  403.  
  404. End
  405.  
  406.  
  407. RefreshWindow:
  408.  
  409.   Gosub DisableDel
  410.  
  411.   Gosub DisableWarp3D
  412.  
  413.   Gosub RefreshScreenMode
  414.  
  415.   SetStringText(1, PL()\Item)
  416.   SetStringText(2, PL()\Command)
  417.  
  418.   If PL()\Command<>""
  419.     DisableGadget(17, 0)
  420.   Else
  421.     DisableGadget(17, 1)
  422.   Endif
  423.  
  424.   GadgetAttrs (7, #GTCY_Active, PL()\Processors)
  425.   GadgetAttrs (8, #GTCY_Active, PL()\Rendering)
  426.   GadgetAttrs (21,#GTCY_Active, PL()\AGA)
  427.  
  428.   GadgetAttrs (13,#GTCB_Checked, PL()\Warp3D)
  429.  
  430.   RefreshGadget(1)
  431.   RefreshGadget(2)
  432.   RefreshGadget(7)
  433.   RefreshGadget(8)
  434.  
  435. Return
  436.  
  437.  
  438. SavePrefs:
  439.   If CreateFile(0,"PROGDIR:WildManager.pref")
  440.  
  441.     WriteString("WildManagerPref1")
  442.     WriteWord(NbProg)
  443.  
  444.     ResetList(PL())
  445.  
  446.     For k=0 To NbProg-1
  447.       If NextElement(PL())
  448.         WriteString(PL()\Item)
  449.         WriteString(PL()\Command)
  450.  
  451.         WriteByte(PL()\Processors)
  452.         WriteByte(PL()\Rendering)
  453.         WriteByte(PL()\Warp3D)
  454.  
  455.         WriteWord(PL()\Width)
  456.         WriteWord(PL()\Height)
  457.         WriteLong(PL()\ScreenID)
  458.         WriteByte(PL()\AGA)
  459.       EndIf
  460.  
  461.       WriteString("WAM_End_WAM")
  462.     Next
  463.  
  464.     CloseFile(0)
  465.   EndIf
  466.  
  467.   ResetList(PL())
  468.  
  469.   For k=0 To NbProg-1
  470.     If NextElement(PL())
  471.       If PL()\Changed
  472.         Gosub SetPref
  473.       EndIf
  474.     EndIf
  475.   Next
  476.  
  477. Return
  478.  
  479.  
  480. DisableDel:
  481.  
  482.   If CountList(PL()) = 1
  483.     DisableGadget(15, 1)
  484.   Else
  485.     DisableGadget(15, 0)
  486.   EndIf
  487.  
  488. Return
  489.  
  490.  
  491. DisableWarp3D:
  492.  
  493.   If PL()\Rendering<>3
  494.     DisableGadget(13, 1)
  495.   Else
  496.     DisableGadget(13, 0)
  497.   EndIf
  498.  
  499. Return
  500.                                                                                                                               
  501.  
  502.  
  503. String1:
  504.   PL()\Item = GetStringText(1)
  505.   GadgetAttrs(9, #GTLV_Labels, *RealList)
  506.   RefreshGadget(9)
  507. Return
  508.  
  509.  
  510. String2:
  511.   PL()\Command = GetStringText(2)
  512.  
  513.   If PL()\Command<>""
  514.     DisableGadget(17, 0)
  515.   Else
  516.     DisableGadget(17, 1)
  517.   EndIf
  518.  
  519.   RefreshGadget(17)
  520.  
  521.   PL()\Changed = 1
  522.  
  523. Return
  524.  
  525.  
  526. SetPref:
  527.  
  528.   If PL()\Processors = 0
  529.  
  530.     Param$ = "TD Monkey"
  531.  
  532.     If PL()\Rendering = 0 ; Special case for WireFrame
  533.       Param$ = Param$ + " DI TryZkren"
  534.     Else
  535.  
  536.       If PL()\AGA
  537.         Param$ = Param$ + " DI TryPeJam+"
  538.       Else
  539.         Param$ = Param$ + " DI Cyborg"
  540.       EndIf
  541.  
  542.     EndIf
  543.  
  544.  
  545.     Select PL()\Rendering
  546.  
  547.       Case 0 ; 'Wire'
  548.         Param$ = Param$ + " DW Wire BK no LI no"
  549.  
  550.       Case 1 ; 'Flat'
  551.         Param$ = Param$ + " DW Flat BK NiX+ LI Flash"
  552.  
  553.       Case 2 ; 'Gouraud'
  554.         Param$ = Param$ + " DW Fluff BK ShiX LI Torch"
  555.  
  556.       Case 3 ; 'Textured'
  557.         Param$ = Param$ + " DW Candy+ BK TiX+ LI Torch"
  558.  
  559.     EndSelect
  560.  
  561.   Else
  562.  
  563.     Param$ = "TD Evolution"
  564.  
  565.     If PL()\Rendering = 0 ; Special case for WireFrame
  566.       Param$ = Param$ + " DI TryZkren"
  567.     Else
  568.  
  569.       If PL()\AGA
  570.         Param$ = Param$ + " DI TryNoe8"
  571.       Else
  572.         Param$ = Param$ + " DI Cyborg"
  573.       EndIf
  574.  
  575.     EndIf
  576.  
  577.  
  578.     Select PL()\Rendering
  579.  
  580.       Case 0 ; 'Wire'
  581.         Param$ = Param$ + " DW Wire BK no LI no"
  582.  
  583.       Case 1 ; 'Flat'
  584.         Param$ = Param$ + " DW Flat BK NiX+ LI Flash"
  585.  
  586.       Case 2 ; 'Gouraud'
  587.         Param$ = Param$ + " DW Fluff BK ShiX LI WTorch"
  588.  
  589.       Case 3 ; 'Textured'
  590.         Param$ = Param$ + " DW PowerDragon BK WTiX LI WTorch"
  591.  
  592.     EndSelect
  593.  
  594.   EndIf
  595.  
  596.  
  597.   If PL()\Warp3D
  598.     If PL()\Processors = 0
  599.       Param$ = "TD Monkey LI Torch"
  600.     Else
  601.       Param$ = "TD Evolution LI WTorch"
  602.     EndIf
  603.  
  604.     Param$ = Param$ + " DW DrScott DI CyborgHi BK no"
  605.   EndIf
  606.  
  607.  
  608.   If PL()\Width
  609.     Param$ = Param$+" WID "+Str(PL()\Width)+" HEI "+Str(PL()\Height);+" MODEID $";+Hex$(\ScreenID)
  610.   EndIf
  611.  
  612.   c$ = GetFilePart(PL()\Command)
  613.  
  614.   If c$ <> ""
  615.     RunProgram("WildPJ:Tools", "CloseWild", 0, 4096)
  616.     RunProgram("WildPJ:Tools", "SetWildAppPrefs "+c$+" save "+Param$, 0, 4096)
  617.   EndIf
  618.  
  619. Return
  620.  
  621.  
  622. RefreshScreenMode:
  623.  
  624.   If PL()\Width
  625.     Mode = Str(PL()\Width)+"x"+Str(PL()\Height)
  626.   Else
  627.     Mode = "Default"
  628.   EndIf
  629.  
  630.   GadgetAttrs(20, #GTTX_Text, Mode)
  631.   RefreshGadget(20)
  632.  
  633. Return
  634.  
  635.